const mongoose = require('mongoose');
const pagination = require('mongoose-sex-page');

const { Article } = require('../../model/article.js')

module.exports = async (req, res) => {
    // console.log(req.params.page);
    var { page } = req.params
    try {
        var data = await pagination(Article).find({status:true}).select('_id title publishDate').sort({publishDate:-1}).page(page).size(7).exec()
    } catch {
        return res.send({
            data: null,
            meta: {
                status: 400,
                msg: '请求失败'
            }
        })
    }
    res.send({
        data,
        meta: {
            status: 200,
            msg: '请求成功'
        }
    })
}